define(
   [
      'dojo/_base/declare',
      'dojo/_base/lang',
      'dojox/grid/EnhancedGrid',
      'dojox/grid/enhanced/plugins/IndirectSelection'
   ],
   function(declare, lang, EnhancedGrid, IndirectSelection)
   {
      return declare([EnhancedGrid],
      {
         style: "table { margin: 0; } html, body { width: 100%; height: 100%; margin: 0; }",
         constructor: function(args)
         {
            dojo.safeMixin(this, args);
         },
         postscript: function(args)
         {
            this.inherited(arguments);
      
            this.deferred = null;
            this.timer = null;
      
            dojo.connect(this, 'onCellMouseOut', function(e){
               dijit.hideTooltip(e.cellNode);
               if(this.deferred)
               {
                  this.deferred.cancel();
               }
               if(this.timer)
               {
                  this.timer.stop();
               }
            });
      
            dojo.connect(this, 'onCellMouseOver', function(e)
            {
               var cellIndex  = e.cellIndex;
               var rowIndex   = e.rowIndex;
               if(rowIndex < 0)
                  return;
      
               var item = e.grid.getItem(e.rowIndex);
               if(!item)
                  return;
      
               require(['dojox/timing'], lang.hitch(this, function(timing){
                  this.timer = new timing.Timer(500);
                  var that = this;
                  this.timer.onTick = function()
                  {
                     that.deferred = that.getHover(item, e);
                     that.timer.stop();
                  };
                  this.timer.start();
               }));
            });
      
            dojo.connect(this, 'onRowDblClick', function(e)
            {
               var item = e.grid.getItem(e.rowIndex);
               this.rowDblClicked(item, e.rowIndex, e);
            });
            dojo.connect(this, 'onRowClick', function(e)
            {
               var item = e.grid.getItem(e.rowIndex);
               this.rowClicked(item, e.rowIndex, e);
            });
      
         },
         getHover: function(item, e)
         {
            return null;
         },
         rowClicked: function(pItem, rowIndex, pEvent)
         {
         },
         rowDblClicked: function(pItem, rowIndex, pEvent)
         {
         }
      });
   }
);
